﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using BIZ;
using DomainModel;
using System.Web.Script.Serialization;
using System.Collections;

namespace joyAdmin.Controllers
{
    [DomainConfirmationFilter]
    [BIZ.AdminFilter]
    public class webController : Controller
    {
        //
        // GET: /web/
        BIZ.WebInfomationPublishOper ips = new WebInfomationPublishOper();
        public ActionResult jlbczjl()
        {
            cmsOper.CheckUserRights("czjl");
            return View();
        }
        public ActionResult jlbxngg()
        {
            cmsOper.CheckUserRights("xngg");
            return View();
        }
        public ActionResult jlbzxkt()
        {
            cmsOper.CheckUserRights("zxkt");
            return View();
        }
        public ActionResult kctsxqk()
        {
            cmsOper.CheckUserRights("tsxqk");
            return View();
        }
        public ActionResult kcyykc()
        {
            cmsOper.CheckUserRights("yykc");
            return View();
        }
        public ActionResult newshydt()
        {
            cmsOper.CheckUserRights("hydt");
            return View();
        }
        public ActionResult newsxxgg()
        {
            cmsOper.CheckUserRights("xxgg");
            return View();
        }
        public ActionResult newsxxhd()
        {
            cmsOper.CheckUserRights("xxhd");
            return View();
        }
        public ActionResult newsxxxw()
        {
            cmsOper.CheckUserRights("xxxw");
            return View();
        }
        public ActionResult sylbgg()
        {
            cmsOper.CheckUserRights("lbgg");
            return View();
        }
        public ActionResult sylxsf()
        {
            cmsOper.CheckUserRights("lxsf");
            return View();
        }
        public ActionResult xyhdzs()
        {
            cmsOper.CheckUserRights("hdzs");
            return View();
        }
        public ActionResult xyjcsp()
        {
            cmsOper.CheckUserRights("jcsp");
            return View();
        }
        public ActionResult xyjwzx()
        {
            cmsOper.CheckUserRights("jwzx");
            return View();
        }

        public ActionResult xymxjt()
        {
            cmsOper.CheckUserRights("mxjt");
            return View();
        }
        public ActionResult xyzpzs()
        {
            cmsOper.CheckUserRights("zpzs");
            return View();
        }
        public ActionResult xzjw()
        {
            cmsOper.CheckUserRights("xzjw");
            return View();
        }
        public ActionResult zygq()
        {
            cmsOper.CheckUserRights("gq");
            return View();
        }
        public ActionResult zyjfzl()
        {
            cmsOper.CheckUserRights("jfzl");
            return View();
        }
        public ActionResult zyjwzmxz()
        {
            cmsOper.CheckUserRights("jwzmxz");
            return View();
        }
        public ActionResult zyjyzyfx()
        {
            cmsOper.CheckUserRights("jyzsfx");
            return View();
        }
        public ActionResult zywztj()
        {
            cmsOper.CheckUserRights("wztj");
            return View();
        }
        public ActionResult sygg()
        {
            cmsOper.CheckUserRights("sygg");
            return View();
        }

        public JsonResult getlist()
        {
            int pageno = Convert.ToInt32(Request.Params["pageno"]);
            int pagesize = Convert.ToInt32(Request.Params["pagesize"]);
            int template = Convert.ToInt32(Request.Params["template"]);
            return Json(ips.getlist(pageno, pagesize, template));
        }
        [ValidateInput(false)]
        public ActionResult saveInfomationPublish()
        {
            WebInfomationPublish _staff = new JavaScriptSerializer().Deserialize<WebInfomationPublish>(Request.Form["WebInfomationPublish"].ToString());

            if (_staff.Wi_id != 0)
            {
                _staff.Wi_updateTime = DateTime.Now;
                _staff.Wi_lastUser = ((DomainModel.cmsuser)Session["cmsuser"]).id;
                _staff.Wi_addTime = _staff.Wi_addTime.ToLocalTime();
                _staff.Wi_startTime = _staff.Wi_startTime.ToLocalTime();
                _staff.Wi_endTime = _staff.Wi_endTime.ToLocalTime();
            }
            else
            {
                _staff.Wi_addTime = DateTime.Now;
                _staff.Wi_user = ((DomainModel.cmsuser)Session["cmsuser"]).id;
            }
            if (_staff.Wi_classRule != null && _staff.Wi_classRule != "")
            {
                _staff.Wi_classRule = "," + _staff.Wi_classRule + ",";
            }
            ips.save(_staff);
            return Json(_staff);
        }
        public JsonResult getinfomationbyid()
        {
            int id = Convert.ToInt32(Request.Params["res"]);
            IList list = ips.getinfomationbyid(id);
            if (list.Count > 0)
                return Json(list[0]);
            else
                return Json("");
        }

        public JsonResult deleteinfomation()
        {
            int id = int.Parse(Request.Form["res"]);

            return Json(ips.delete(id));
        }
    }
}
